#include "../Client/RpcClient.hpp"
#include <unistd.h>
#include <chrono>
int main()
{
    // Rpc客户端启动服务查询的话就是传入服务中心的ip和端口了
    RpcClient::RpcClient Client(true, "127.0.0.1", 9090);
    // 构建一条rpc请求对象
    Json::Value paras;
    paras["nums1"] = 6;
    paras["nums2"] = 2;

    // // 构建一条主题请求信息的正文部分
    // auto TopicRequest = Message::BuildMessage::build<Message::TopicRequest>();
    // TopicRequest->SetMtype(Rs_RqType::TOPIC_Req);
    // TopicRequest->SetUuid(UUID::uuid());
    // TopicRequest->SetTopic("Music");
    // TopicRequest->SetTopOper(TopicOperType::Topic_SubScribe);

    Json::Value paras1, result;
    paras1["nums1"] = 60;
    paras1["nums2"] = 20;
    std::future<Abstract::BaseMessage::MesaPtr> RpcFuture;
    std::string uuid;
    long i = 0 ;auto start = std::chrono::high_resolution_clock::now();
    while (i < 50000) // 主线程负责发送消息然后阻塞等待监听线程结束消息
    {
        Client.call("Add", paras1, result);
        // std::cout << result["Res"].asInt() << std::endl;
        //Client.call("Div", paras1, result);
        // std::cout << result["Res"].asInt() << std::endl;
       i++;
    }
    auto end = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> tsum = end - start;
    std::cout << "发送50000次Rpc请求" <<  " 接收回应耗时：" << tsum.count() << "s" << std::endl;
    std::cout<<"每秒钟接收的回应数量:"<<(size_t)(50000/tsum.count())<<std::endl;
}